package 力扣日常刷题.木23一月.第03天303;

/**
 * @author 帅小伙
 * @date 2022/3/3
 * @description
 */
public class Demo30各位相加 {

    public static void main(String[] args) {
        addDigits(38);
    }

    public static int addDigits(int num) {
        int ans = num;

        while(ans >= 10) {
            num = ans;
            ans = 0;
            while(num != 0){
                ans += (num % 10);
                num /= 10;
            }
        }
        return ans;
    }

}
